  function plusReady() {
  	// 弹出系统选择按钮框  
  	//              mui("body").on("tap",".imageup",function(){  
  	//                  page.imgUp();  
  	//              })  

  }

  function selectImg(idName) {
  	page.imgUp(idName);
  }
  var page = null;
  page = {
  	imgUp: function(idName) {
  		var m = this;
  		plus.nativeUI.actionSheet({
  			cancel: "取消",
  			buttons: [{
  					title: "拍照"
  				},
  				{
  					title: "从相册中选择"
  				}
  			]
  		}, function(e) { //1 是拍照  2 从相册中选择  
  			switch(e.index) {
  				case 1:
  					appendByCamera(idName);
  					break;
  				case 2:
  					appendByGallery(idName);
  					break;
  			}
  		});
  	}
  	//摄像头  
  }

  // 拍照添加文件
  function appendByCamera(idName) {
  	plus.camera.getCamera().captureImage(function(e) {
  		console.log(e);
  		plus.io.resolveLocalFileSystemURL(e, function(entry) {
  			var path = entry.toLocalURL();
  			document.getElementById(idName).src = path;
  			//就是这里www.bcty365.com 
  		}, function(e) {
  			mui.toast("读取拍照文件错误：" + e.message);
  		});

  	});
  }
  // 从相册添加文件
  function appendByGallery(idName) {
  	plus.gallery.pick(function(path) {
  		document.getElementById(idName).src = path;

  	});
  }

  //服务端接口路径
  var server = 'http://192.168.191.1:8080/goods/pubGoods.do';
  //获取图片元素
  //var files = document.getElementById('headimg');
  var files = [];
  files[0] = document.getElementById('headimg1');
  files[1] = document.getElementById('headimg2');
  files[2] = document.getElementById('headimg3');
  // 上传文件
  function upload(parms) {
  	//	console.log(files.src);
  	var wt = plus.nativeUI.showWaiting();

  	var task = plus.uploader.createUpload(server, {
  			method: "POST",
  		},
  		function(t, status) { //上传完成
  			
  			var respone = t.responseText;
  			console.log(JSON.stringify(respone));
  			checkUserIsOnline(respone);

  			if(respone.resultCode == REQUEST_SUCCESS_CDOE) {
  				wt.close(); //关闭等待提示按钮
  				mui.toast(respone.msg, {
  					duration: 'long',
  					type: 'div'
  				})
  				setTimeout(() => { //设置定时器，等用户看清楚了提示再关闭窗口
  					//关闭当前窗口
  					mui.back();
  				}, 2000);
  			} else {
  				wt.close(); //关闭等待提示按钮
  				mui.toast(respone.msg, {
  					duration: 'long',
  					type: 'div'
  				})

  			}

  		}

  	);

  	task.addData("title", parms.title); //标题
  	task.addData("stuIdToken", parms.stuIdToken);
  	task.addData("loginToken", parms.loginToken);
  	task.addData("des", parms.des); //描述
  	task.addData("price", parms.price); //价格
  	task.addData("campus", parms.campus); //地区
  	task.addData("originalPrice", parms.originalPrice);
  	task.addData("goodsType", parms.goodsType); //类型

  	var ADD_IMG = "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/apps/HBuilder/www/images/g3.png";
  	for(var i = 0; i < files.length; i++) {
  		console.log(files[i].src);
  		if(files[i].src != ADD_IMG) {
  			task.addFile(files[i].src, {
  				key: "pic" + i
  			});
  		}
  	}
  	task.start();

  }

  if(window.plus) {
  	plusReady();
  } else {
  	document.addEventListener("plusready", plusReady, false);
  }